package com.framework.workflow.controller;

import com.framework.common.domain.ResultData;
import com.framework.workflow.model.WfButton;
import com.framework.workflow.params.WfButtonParam;
import com.framework.workflow.service.IWfButtonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @description: 流程按钮 Service
 * @author: ywenbo
 * @version: 1.0
 * @date: 2021-10-21 09:07:45
 */
@RestController
@RequestMapping("/wfButton")
@Api(value = "WfButton", tags = "流程按钮")
public class WfButtonController {
    @Autowired
    private IWfButtonService baseService;


    @ResponseBody
    @ApiOperation(value = "新增")
    @PostMapping(value = "/add")
    public ResultData<?> add(@RequestBody WfButton param) {
        baseService.save(param);
        return ResultData.success();
    }

    @ResponseBody
    @ApiOperation(value = "新增")
    @PostMapping(value = "/addSimple")
    public ResultData<?> addSimple(@RequestBody WfButton param) {
        baseService.addSimple(param);
        return ResultData.success();
    }

    @ResponseBody
    @ApiOperation(value = "删除")
    @PostMapping(value = "/del")
    public ResultData<?> delete(@RequestBody List<String> ids) {
        baseService.delete(ids);
        return ResultData.success();
    }

    @ResponseBody
    @ApiOperation(value = "根据流程key删除按钮")
    @PostMapping(value = "/delByKey")
    public ResultData<?> delByKey(String key) {
        baseService.delByKey(key);
        return ResultData.success();
    }

    @ResponseBody
    @ApiOperation(value = "编辑")
    @PostMapping(value = "/edit")
    public ResultData<?> edit(@RequestBody WfButton param) {
        baseService.update(param);
        return ResultData.success();
    }

    @ApiOperation(value = "查看")
    @GetMapping(value = "/findOne")
    public ResultData<?> findOne(@RequestParam String id) {
        WfButton entity = baseService.findOne(id);
        return ResultData.data(entity);
    }

    @ApiOperation("获取分页")
    @PostMapping(value = "/list")
    public ResultData<?> list(@RequestBody WfButtonParam param) {
        List<WfButton> list = baseService.list(param);
        return ResultData.data(list);
    }

    @ApiOperation("获取当前流程按钮")
    @PostMapping(value = "/listBtn")
    public ResultData<?> listCurrNode(@RequestBody WfButtonParam param) {
        List<WfButton> users = baseService.listCurrNodeBtn(param);
        return ResultData.data(users);
    }
}
